package com.dynamic.model.dao.impl;

import java.util.ArrayList;
import java.util.List;

import com.dynamic.model.common.dao.impl.BaseDaoImpl;
import com.dynamic.model.common.vo.Page;
import com.dynamic.model.dao.SystemCodeDaoI;
import com.dynamic.model.model.po.SystemCode;
import org.springframework.stereotype.Repository;

@Repository
public class SytemCodeDaoImpl extends BaseDaoImpl<SystemCode> implements SystemCodeDaoI {

	@Override
	public List<SystemCode> getPageDataReqName(Page<SystemCode> page, String key) {
		List<Object> prams=new ArrayList<Object>();
		String hql="from SystemCode t where t.deleteFlag = 0 ";
		if(null!=key&&key.length()>0){
			hql=hql+" and t.codeKey like ?";
			prams.add("%"+key+"%");
		}
		hql=hql+" order by t.createTime desc,pid desc";
		return this.queryForList(hql, prams, page );
	}

	@Override
	public SystemCode getCodeByKey(String key) {
		String hql = "from SystemCode where codeKey = ? and deleteFlag=0" ;
		return this.queryForObject(hql, new Object[]{key});
	}
	
}
